package com.ilancuo.template.factory;

/**
 * Created by ilancuo on 2016/12/18.
 */
public class FoodFactory {
    public static Food getFood(String name) throws IllegalAccessException, InstantiationException {
        if (name.equalsIgnoreCase("milk")) {
            return Milk.class.newInstance();
        } else if (name.equalsIgnoreCase("bread")) {
            return Bread.class.newInstance();
        } else {
            System.out.println("no instance...");
            return null;
        }
    }
}
